<?
 session_start();
 if (@$_SESSION['client']==0) { header('Location: /login.php');};

 require_once("core.php");

 get_all_variables();
 $db = dbconnect();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>openOli | History</title>
<link rel="icon" href="img/favicon.png" type="image/png" />
<link href="css/yahoo_reset.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/history.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
      $(document).ready(function(){
        setInterval(function(){$("#timebox").load("time.php");}, 30000);
        })
</script>
</head>

<body>
  <!-- openOli::Contest | Turan Rustamli -->
  <div id="page">
  
    <div id="hdtext">
	   <div id="hdt_l">open source web based judge for holding olympiads in informatics</div>
	   <div id="hdt_r">English &nbsp; <img src="img/ico_mail.gif" alt="openOli" border="0"> &nbsp; <img src="img/ico_home.gif" alt="openOli" border="0"></div>
	</div>
    
	<div id="header">
	   <div id="logo"><a href="dashboard.php"><img src="img/logo.jpg" alt="openOli" border="0"></a></div>
	   <div id="topmenu">
	        <a class="foxbtn" href="dashboard.php"><span>Dashboard</span></a>
	        <a class="foxbtn" href="problems.php"><span>Problems</span></a>
            <a class="foxbtn" href="submit.php"><span>Submit</span></a>
            <a class="foxbtn" href="test.php"><span>Test</span></a>
            <a class="foxbtn_x" href="archive.php"><span>History</span></a>
            <a class="foxbtn" href="help.php"><span>Help</span></a>
            <a class="foxbtn" href="logout.php"><span>Log out</span></a>
	   </div> 	    
	   <div id="toolbox">		  
		  <div id="timebox">
	          <? include('time.php'); ?>
		  </div>
		</div> 	    
	</div>
	
	<div id="content">
       <p class="p_title">Submitions archive</p>
       <div style="margin-left: 10px;">
          The score for every problem will be counted for last submition.
       </div>
       <br/>
       <div class="subsection">
         <h2>Problem A. <b>Stacks</b></h2>
         <br/>
         <table border="0" width="500" class="histable">
                 <tr>
                     <th>Time</th>
                     <th>Status</th>
                     <th>Source</th>
                 </tr>
                 <? 
                 $q = "SELECT * FROM `submits` WHERE (problem_id='A') AND (client_id=$client)";
                 $r = mysql_query($q, $db) or die(mysql_error());
                 $n = mysql_num_rows($r);
                 for ($i=0; $i<$n; $i++){
                    $w = mysql_fetch_array($r); ?>
                 <tr>
                     <td><? echo $w['time']; ?></td>
                     <td><? if ((int)$w['test']>3){ echo "Accepted";} else { echo $w['result'];}; ?></td>
                     <td><a href="source.php?id=<? echo $w['id']; ?>&lang=<? echo $w['lang']; ?>" target="_blank">Source</a></td>
                 </tr>
                 <? }; ?>
         </table>
             
       </div>

       <div class="subsection">
         <h2>Problem B. <b>Knights of the Round Table</b></h2>
         <br/>
         <table border="0" width="500" class="histable">
                 <tr>
                     <th>Time</th>
                     <th>Status</th>
                     <th>Source</th>
                 </tr>
                 <?
                 $q = "SELECT * FROM `submits` WHERE (problem_id='B') AND (client_id=$client)";
                 $r = mysql_query($q, $db) or die(mysql_error());
                 $n = mysql_num_rows($r);
                 for ($i=0; $i<$n; $i++){
                    $w = mysql_fetch_array($r); ?>
                 <tr>
                     <td><? echo $w['time']; ?></td>
                     <td><? if ((int)$w['test']>3){ echo "Accepted";} else { echo $w['result'];}; ?></td>
                     <td><a href="source.php?id=<? echo $w['id']; ?>&lang=<? echo $w['lang']; ?>" target="_blank">Source</a></td>
                 </tr>
                 <? }; ?>
         </table>

       </div>

       <div class="subsection">
         <h2>Problem C. <b>Bill Clevers</b></h2>
         <br/>
         <table border="0" width="500" class="histable">
                 <tr>
                     <th>Time</th>
                     <th>Status</th>
                     <th>Source</th>
                 </tr>
                 <?
                 $q = "SELECT * FROM `submits` WHERE (problem_id='C') AND (client_id=$client)";
                 $r = mysql_query($q, $db) or die(mysql_error());
                 $n = mysql_num_rows($r);
                 for ($i=0; $i<$n; $i++){
                    $w = mysql_fetch_array($r); ?>
                 <tr>
                     <td><? echo $w['time']; ?></td>
                     <td><? if ((int)$w['test']>3){ echo "Accepted";} else { echo $w['result'];}; ?></td>
                     <td><a href="source.php?id=<? echo $w['id']; ?>&lang=<? echo $w['lang']; ?>" target="_blank">Source</a></td>
                 </tr>
                 <? }; ?>
         </table>

       </div>

        <div class="subsection">
         <h2>Problem D. <b>Strange sequence.</b></h2>
         <br/>
         <table border="0" width="500" class="histable">
                 <tr>
                     <th>Time</th>
                     <th>Status</th>
                     <th>Source</th>
                 </tr>
                 <?
                 $q = "SELECT * FROM `submits` WHERE (problem_id='D') AND (client_id=$client)";
                 $r = mysql_query($q, $db) or die(mysql_error());
                 $n = mysql_num_rows($r);
                 for ($i=0; $i<$n; $i++){
                    $w = mysql_fetch_array($r); ?>
                 <tr>
                     <td><? echo $w['time']; ?></td>
                     <td><? if ((int)$w['test']>3){ echo "Accepted";} else { echo $w['result'];}; ?></td>
                     <td><a href="source.php?id=<? echo $w['id']; ?>&lang=<? echo $w['lang']; ?>" target="_blank">Source</a></td>
                 </tr>
                 <? }; ?>
         </table>

       </div>
       
      <div class="subsection">
         <h2>Problem E. <b>Hopscotch.</b></h2>
         <br/>
         <table border="0" width="500" class="histable">
                 <tr>
                     <th>Time</th>
                     <th>Status</th>
                     <th>Source</th>
                 </tr>
                 <?
                 $q = "SELECT * FROM `submits` WHERE (problem_id='E') AND (client_id=$client)";
                 $r = mysql_query($q, $db) or die(mysql_error());
                 $n = mysql_num_rows($r);
                 for ($i=0; $i<$n; $i++){
                    $w = mysql_fetch_array($r); ?>
                 <tr>
                     <td><? echo $w['time']; ?></td>
                     <td><? if ((int)$w['test']>3){ echo "Accepted";} else { echo $w['result'];}; ?></td>
                     <td><a href="source.php?id=<? echo $w['id']; ?>&lang=<? echo $w['lang']; ?>" target="_blank">Source</a></td>
                 </tr>
                 <? }; ?>
         </table>

       </div>

	</div>	
	
	<div id="bottom"><span id="b_left">&copy; Turan Rustamli - You may use openOli under the terms of the MIT License.</div></div>	
	<br />
  </div>
</body>
</html>
